home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / videbjct / pnr6000d.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  21.1 KB  |  684 lines

  1. /*
  2.  * Copyright (c) 1990, 1991, 1992 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/VideoObject/RCS/Pioneer6000Driver.c,v 0.20 92/09/28 12:40:00 drapeau Exp $ */
  25. /* $Log:    Pioneer6000Driver.c,v $
  26.  * Revision 0.20  92/09/28  12:40:00  drapeau
  27.  * PlayFromTo() was modified to reflect the new semantics of the VideoObject
  28.  * library.
  29.  * 
  30.  * Revision 0.19  92/07/30  15:27:18  drapeau
  31.  * Several changes:
  32.  * * Re-formatted all function declarations to conform to ANSI function
  33.  *   prototype standards.
  34.  * * Replaced hard-coded references to 30 frame-per-second frame rates with
  35.  *   new definition "FrameRate".  All math is based on this definition now,
  36.  *   allowing the driver to be used in places where the frame rate is not
  37.  *   30 fps.
  38.  * * Improved diagnostic messages.  Diagnostics now report the serial port
  39.  *   being used for the command when possible.
  40.  * 
  41.  * Revision 0.18  91/09/30  17:07:05  lim
  42.  * Implemented Pioneer6000Ping.
  43.  * Renamed Power as MyPower.
  44.  * 
  45.  * Revision 0.17  91/08/24  17:50:10  lim
  46.  * Implemented PrintDiagnostics.
  47.  * 
  48.  * Revision 0.16  91/08/24  13:38:09  lim
  49.  * 1. Updated to use status codes in new PlayerStatus.h
  50.  * 2. Clear Marker() removed as part of video object.
  51.  * 
  52.  * Revision 0.15  91/08/17  20:40:44  lim
  53.  * 1. Removed 'stopped'. Video mute is turned off whenever a command
  54.  * requiring video output is issued.
  55.  * 2.  Stop and Pause implemented with interrupt capability.
  56.  * 3. Clear Marker implemented to do as specs in videoObj.h require.
  57.  * 
  58.  * Revision 0.14  91/08/08  17:18:05  lim
  59.  * 1. PlayAtSpeedDir() - try to input device-dependent speed rather than an arbitrary speed.
  60.  *    ie use CalcSpeed before calling PlayAtSpeedDir()
  61.  * 2. CalcSpeed() - one parameter added, 'playMode'. If playMode is 1, it is used to calculate
  62.  *    device speed for segment play. If playMode is 0, it is used to calculate device speed for
  63.  *    normal play.
  64.  * 
  65.  * Revision 0.13  91/08/07  13:16:41  lim
  66.  * 1. Made as part of VideoLib.a. Removed references to vEdit application.
  67.  * 2. Added instance pointer, "theObject" to all public functions. 
  68.  * 
  69.  * Revision 0.12  91/08/02  12:52:43  lim
  70.  * 1. SetDefaults function changed to take in 4 parameters"
  71.  * audio, addressingMode, addressDisplayOnOff, and displayMode
  72.  * 2. xv_set is no longer called within driver code, but from
  73.  * vEdit application.
  74.  * 3. Pause is removed.
  75.  * 
  76.  * Revision 0.11  91/07/29  22:28:27  lim
  77.  * Status codes updated to conform with specs.
  78.  * 
  79.  * Revision 0.10  91/07/27  22:18:35  lim
  80.  * Initial revision.
  81.  *  */
  82.  
  83. #include "Pioneer6000Driver.h"
  84.  
  85. static char pioneer6000Rcs[] = "$Header: /Source/Media/collab/VideoObject/RCS/Pioneer6000Driver.c,v 0.20 92/09/28 12:40:00 drapeau Exp $";
  86.  
  87. static int    sliderControl = 1;
  88. static char    diagMsg[64];
  89.  
  90.  
  91. /* Convert integer to Pioneer6000 code. */
  92.  
  93. void
  94.   IntToCode(int num, char* code)
  95. {
  96.   char    tempString[11];
  97.   int    i = 0;
  98.   int    first = 1;
  99.   int    count;
  100.   
  101.   while ((num != 0) || (first != 0))                    /* Convert digit by digit to code, starting from ... */
  102.   {                                    /* ... least significant and storing into tempString */
  103.     switch (num%10)
  104.     {
  105.      case 0:
  106.       strcpy(&tempString[i], "3F");
  107.       break;
  108.      case 1:
  109.       strcpy(&tempString[i], "0F");
  110.       break;
  111.      case 2:
  112.       strcpy(&tempString[i], "8F");
  113.       break;
  114.      case 3:
  115.       strcpy(&tempString[i], "4F");
  116.       break;
  117.      case 4:
  118.       strcpy(&tempString[i], "2F");
  119.       break;
  120.      case 5:
  121.       strcpy(&tempString[i], "AF");
  122.       break;
  123.      case 6:
  124.       strcpy(&tempString[i], "6F");
  125.       break;
  126.      case 7:
  127.       strcpy(&tempString[i], "1F");
  128.       break;
  129.      case 8:
  130.       strcpy(&tempString[i], "9F");
  131.       break;
  132.      case 9:
  133.       strcpy(&tempString[i], "5F");
  134.       break;
  135.     }
  136.     num/=10;
  137.     first = 0;
  138.     i+=2;
  139.   }
  140.   tempString[i] = '\0';
  141.   count = strlen(tempString) - 2;
  142.   for (i = 0; i <= count; i+=2)                        /* tempString is reversed, so we put into code in right ... */
  143.     strncpy(&code[i], &tempString[count-i], 2);                /* ... order */
  144.   code[strlen(tempString)] = '\0';
  145.   return;
  146. }                                    /* end function IntToCode */
  147.  
  148.  
  149. /* Calculates base to the power of expon */
  150. int
  151.   MyPower(int base, int expon)
  152. {
  153.   int i;
  154.   int p = 1;
  155.   
  156.   for (i = 1; i <= expon; i++)
  157.     p = p*base;
  158.   return p;
  159. }                                    /* end function MyPower */
  160.  
  161.  
  162. /* Converts character "hex code" for frame address to integer */
  163.  
  164. int
  165.   CodeToInt(char* code)
  166. {
  167.   int i;
  168.   int frame = 0;
  169.   
  170.   for (i = 4; i > 0; i--)
  171.   {
  172.     if ((code[i-1] > 64) && (code[i-1] < 71))                /* Character is between 'A' and 'F' */
  173.       frame += (((int) code[i-1]) - 55) * MyPower(16, (4-i));
  174.     else                                /* Character is between '0' and '9' */
  175.       frame += (((int) code[i-1]) - 48) * MyPower(16, (4-i));
  176.   }
  177.   return frame;
  178. }                                    /* end function CodeToInt */
  179.  
  180.  
  181. void
  182.   Pioneer6000LoadSegmentPlayProgram(VideoObject* theObject)
  183. {
  184.   
  185.   /* Program                      - Start programming mode
  186.      0 Get                        - Put 0 in Register 0
  187.      5 Recall                     - Recall and activate Register 5 (it stores whether address display is on/off)
  188.      5 Arg Com                    - Use Register 5 as an argument and compare with Register 0
  189.      19 Branch                    - If Register 0 > Register 5, branch to address 19 (Off)
  190.      19 Branch                    - If Register 0 = Register 5, branch to address 19  "
  191.      16 Branch                    - If Register 0 < Register 5, branch to address 16 (On)
  192.      CharacterGeneratorEnable     - Address 16: Set character generator on
  193.      1 Display                    - Set address display on
  194.      6 Recall                     - Address 19: Recall and activate Register 6 (it stores start frame)
  195.      6 Arg Com                    - Use Register 6 as an argument and compare with Register 0
  196.      36 Branch                    - If Register 0 > Register 6, branch to address 36 (0)
  197.      36 Branch                    - If Register 0 = Register 6, branch to address 36 (0)
  198.      33 Branch                    - If Register 0 < Register 6, branch to address 33 (Non-zero)
  199.      6 Arg Search                 - Address 33: Use Register 6 to search 
  200.      7 Arg Com                    - Use Register 7 as an argument and compare with Register 0
  201.      52 Branch                    - If Register 0 > Register 7, branch to address 52 (Play continuously)
  202.      52 Branch                    - If Register 0 = Register 7, branch to address 52 (Play continuously)
  203.      48 Branch                    - If Register 0 < Register 7, branch to address 48 (Play segment)
  204.      7 Arg MultiSpeedForward      - Address 48: Use Register 7 as argument and play forward
  205.      Halt                         - End automatic mode and return to manual mode
  206.      Play                         - Address 52: Play
  207.      Halt                         - End automatic mode and return to manual mode
  208.      End                          - End programming mode and return to manual mode
  209.      
  210.      The code according to the lines above becomes :
  211.      DF
  212.      0:   3F 08
  213.      AF 7F
  214.      AF 0A 04
  215.      0F 5F CF
  216.      0F 5F CF
  217.      0F 6F CF
  218.      16:  E0
  219.      0F F1
  220.      19:  6F 7F
  221.      6F 0A 04
  222.      4F 6F CF
  223.      4F 6F CF
  224.      4F 4F CF
  225.      33:  6F 0A F7
  226.      36:  1F 0A 04
  227.      AF 8F CF
  228.      AF 8F CF
  229.      2F 9F CF
  230.      48:  1F 0A F2
  231.      BF
  232.      52:  FD F2 F7               - This is the only way we can enter 'PLAY' into the RAM
  233.      BF
  234.      EF
  235.      
  236.      Register 5 : Address Display
  237.      Register 6 : Start address
  238.      Register 7 : End address
  239.      
  240.      */
  241.   Pioneer6000SendCode(theObject, "DF", 0);
  242.   Pioneer6000SendCode(theObject, "3F08", 0);
  243.   Pioneer6000SendCode(theObject, "AF7F", 0);
  244.   Pioneer6000SendCode(theObject, "AF0A04", 0);
  245.   Pioneer6000SendCode(theObject, "0F5FCF", 0);
  246.   Pioneer6000SendCode(theObject, "0F5FCF", 0);
  247.   Pioneer6000SendCode(theObject, "0F6FCF", 0);
  248.   Pioneer6000SendCode(theObject, "E0", 0);
  249.   Pioneer6000SendCode(theObject, "0FF1", 0);
  250.   Pioneer6000SendCode(theObject, "6F7F", 0);
  251.   Pioneer6000SendCode(theObject, "6F0A04", 0);
  252.   Pioneer6000SendCode(theObject, "4F6FCF", 0);
  253.   Pioneer6000SendCode(theObject, "4F6FCF", 0);
  254.   Pioneer6000SendCode(theObject, "4F4FCF", 0);
  255.   Pioneer6000SendCode(theObject, "6F0AF7", 0);
  256.   Pioneer6000SendCode(theObject, "1F0A04", 0);
  257.   Pioneer6000SendCode(theObject, "AF8FCF", 0);
  258.   Pioneer6000SendCode(theObject, "AF8FCF", 0);
  259.   Pioneer6000SendCode(theObject, "2F9FCF", 0);
  260.   Pioneer6000SendCode(theObject, "1F0AF2", 0);
  261.   Pioneer6000SendCode(theObject, "BF", 0);
  262.   Pioneer6000SendCode(theObject, "FDF2F7", 0);
  263.   Pioneer6000SendCode(theObject, "BF", 0);
  264.   Pioneer6000SendCode(theObject, "EF", 0);
  265.   return;
  266. }                                    /* end function Pioneer6000LoadSegmentPlayProgram */
  267.  
  268.  
  269.  
  270. /* Disables remote control unit */
  271. void
  272.   Pioneer6000SetRCUOff(VideoObject* theObject)
  273. {
  274.   Pioneer6000SendCode(theObject, "13", 0);
  275.   return;
  276. }                                    /* end function Pioneer6000SetRCUOff */
  277.  
  278.  
  279.  
  280. /* Sets up default values for video options */
  281.  
  282. int
  283.   Pioneer6000SetDefaults(VideoObject*    theObject,
  284.              int        audio,
  285.              int        addressingMode,            /* Unused */
  286.              int        addressDisplayOnOff,
  287.              int        displayMode)
  288. {  
  289.   
  290.   Pioneer6000SetAudio(theObject, audio);                /* Set audio */
  291.   Pioneer6000SetAddressDisplay(theObject, 
  292.                    addressDisplayOnOff, displayMode);   /* Set display */
  293.   
  294.   /* Loads program to perform segment play. */
  295.   /* This is done because in manual mode, there ... */
  296.   /* ... is no buffering of commands and setting ... */
  297.   /* ... an autostop after a search will cause the ... */
  298.   /* ... search to be stopped, regardless of the ... */
  299.   /* ... status of the search. Only in automatic mode ... */
  300.   /* ... will the commands be executed sequentially. */
  301.   Pioneer6000LoadSegmentPlayProgram(theObject);            
  302.   
  303.   Pioneer6000SetRCUOff(theObject);                    /* Turn off remote control */
  304.   return PlayerOk;
  305. }                                    /* end function Pioneer6000SetDefaults */
  306.  
  307.  
  308. int
  309.   Pioneer6000SendCode(VideoObject*    theObject,
  310.               char*        code,
  311.               int        mode)
  312. {
  313.   char response[20];
  314.   int  nr;
  315.   
  316.   sprintf(diagMsg, "%s :\tSending %s.\n",
  317.       theObject->DevConfig->serialPort,
  318.       code);
  319.   PrintDiagnostics(diagMsg);
  320.   write(theObject->DevConfig->fd, code, strlen(code));
  321.   switch (mode)
  322.   {
  323.    case 0:                                /* No response expected */
  324.     return PlayerOk;
  325.    case 1:                                /* Frame number */
  326.     nr = read(theObject->DevConfig->fd, response, 20);
  327.     response[nr-2] = '\0';
  328.     sprintf(diagMsg, "%s :\tReading %s.\n",
  329.         theObject->DevConfig->serialPort,
  330.         response);
  331.     PrintDiagnostics(diagMsg);
  332.     return(CodeToInt(response));
  333.    case 2:                                /* Status */
  334.     nr = read(theObject->DevConfig->fd, response, 20);
  335.     response[nr-2] = '\0';
  336.     sprintf(diagMsg, "%s :\tReading %s.\n",
  337.         theObject->DevConfig->serialPort,
  338.         response);
  339.     PrintDiagnostics(diagMsg);
  340.     if (strcmp(response, "4C") == 0)
  341.       return PlayerScan;
  342.     else if (strcmp(response, "50") == 0)
  343.       return PlayerSearch;
  344.     else if (strcmp(response, "55") == 0)
  345.       return PlayerStop;
  346.     else if (strcmp(response, "E0") == 0)
  347.       return PlayerForwardPlay;
  348.     else if (strcmp(response, "E1") == 0)
  349.       return PlayerForwardStep;
  350.     else if (strcmp(response, "64") == 0)
  351.       return PlayerForwardPlay;
  352.     else if (strcmp(response, "65") == 0)
  353.       return PlayerForwardStep;
  354.     else if (strcmp(response, "66") == 0)
  355.       return PlayerMultiStepFwd;
  356.     else if (strcmp(response, "67") == 0)
  357.       return PlayerMultiStepRev;
  358.     else if (strcmp(response, "68") == 0)
  359.       return PlayerSpinUp;
  360.     else if (strcmp(response, "78") == 0)
  361.       return PlayerPark;
  362.     else if (strcmp(response, "7C") == 0)
  363.       return PlayerEject;
  364.     else 
  365.       return PlayerUnknownReturnCode;
  366.   }                                    /* end switch */
  367. }                                    /* end function Pioneer6000SendCode */
  368.  
  369.  
  370. /*  Player functions  */
  371.  
  372.  
  373. int
  374.   Pioneer6000Still(VideoObject* theObject)
  375. {
  376.   Pioneer6000SendCode(theObject, "BF", 0);                /* Interrupt program play */
  377.   return(Pioneer6000SendCode(theObject, "FB", 0));
  378. }                                    /* end function Pioneer6000Still */
  379.  
  380.  
  381. int
  382.   Pioneer6000Stop(VideoObject* theObject)
  383. {
  384.   Pioneer6000SendCode(theObject, "BF", 0);                /* Interrupt program play */
  385.   Pioneer6000SetVideo(theObject, FeatureOff);
  386.   return(Pioneer6000SendCode(theObject, "FB", 0));                
  387. }                                    /* end function Pioneer6000Stop */
  388.  
  389.  
  390.  
  391. int 
  392.   Pioneer6000Eject(VideoObject* theObject)
  393. {
  394.   Pioneer6000SendCode(theObject, "F9", 0);                /* Eject disc */
  395.   return(Pioneer6000SetDefaults(theObject, PlayerAudioStereo,        /* Reset defaults */
  396.                 PlayerFrameMode, FeatureOn,
  397.                 DisplayFrame));
  398. }                                    /* Pioneer6000Eject */
  399.  
  400.  
  401.  
  402. int
  403.   Pioneer6000Play(VideoObject* theObject)
  404. {
  405.   Pioneer6000SetVideo(theObject, FeatureOn);
  406.   return(Pioneer6000SendCode(theObject, "FD", 0));
  407. }                                    /* end function Pioneer6000Play */
  408.  
  409.  
  410. int
  411.   Pioneer6000SetAddress(VideoObject*    theObject,
  412.             int        add,
  413.             int        start)
  414. {
  415.   char addCode[11];
  416.   char command[20];
  417.   
  418.   IntToCode(add, addCode);
  419.   if (start)
  420.     Pioneer6000SendCode(theObject, "6F7F", 0);                /* Set Register 6 active */
  421.   else
  422.     Pioneer6000SendCode(theObject, "1F7F", 0);                /* Set Register 7 active */
  423.   sprintf(command, "%sF5", addCode);                    /* Set address */
  424.   return(Pioneer6000SendCode(theObject, command, 0));
  425. }                                    /* end function Pioneer6000Play */
  426.  
  427.  
  428. int
  429.   Pioneer6000PlayFromTo(VideoObject*    theObject,
  430.             int        from,
  431.             int        to,
  432.             int        speed)
  433. {
  434.   int deviceSpeed;
  435.   
  436.   if ((from == to) || ((from > 0) && (to == 0)))            /* Case a & b: search to "from" and still.  Since search... */
  437.   {                                    /* ...speed is quick, both cases are equivalent here (i.e.,... */
  438.     return(Pioneer6000Search(theObject, from));                /* ...there is no non-blocking search) */
  439.   }
  440.   if ((from == 0) && (to > 0))                        /* Case c: play from current position until address... */
  441.   {                                    /* ..."to" has been reached. */
  442.     Pioneer6000SetAddress(theObject, to, 0);                /* Set end address */
  443.     Pioneer6000SetAddress(theObject, 0, 1);                /* Continue play from current position */
  444.     sliderControl = 0;
  445.     deviceSpeed = Pioneer6000CalcSpeed(theObject, speed, 0);
  446.     return(Pioneer6000PlayAtSpeedDir(theObject, deviceSpeed, Forward));
  447.   }
  448.   if ((from > 0) && (to > 0) && (from < to))                /* Case d: play from "from" to "to" */
  449.   {
  450.     return(Pioneer6000Search(theObject, from));                /* Search to "from" address */
  451.     Pioneer6000SetAddress(theObject, to, 0);                /* Set end address */
  452.     Pioneer6000SetAddress(theObject, 0, 1);                /* Continue play from current position */
  453.     sliderControl = 0;
  454.     deviceSpeed = Pioneer6000CalcSpeed(theObject, speed, 0);
  455.     return(Pioneer6000PlayAtSpeedDir(theObject, deviceSpeed, Forward));
  456.   }  
  457.   return(PlayerReturnError);                        /* If this code is reached, incorrect from & to were requested */
  458. }                                    /* end function Pioneer6000PlayFromTo */
  459.  
  460.  
  461. int
  462.   Pioneer6000Step(VideoObject*    theObject,
  463.           enum Direction dir)
  464. {
  465.   Pioneer6000SetVideo(theObject, FeatureOn);
  466.   if (dir == Forward)
  467.     return(Pioneer6000SendCode(theObject, "F6", 0));
  468.   else
  469.     return(Pioneer6000SendCode(theObject, "FE", 0));
  470. }                                    /* end function Pioneer6000Step */
  471.  
  472.  
  473.  
  474. int
  475.   Pioneer6000FastForward(VideoObject* theObject)
  476. {  
  477.   
  478.   int i;
  479.   
  480.   Pioneer6000SetVideo(theObject, FeatureOn);
  481.   Pioneer6000Still(theObject);
  482.   for (i = 0; i < 30; i++)
  483.     Pioneer6000SendCode(theObject, "F0", 0);
  484.   return (Pioneer6000Play(theObject));
  485. }                                    /* end function Pioneer6000FastForward */
  486.  
  487.  
  488.  
  489. int
  490.   Pioneer6000Reverse(VideoObject* theObject)
  491. {
  492.   int i;
  493.   
  494.   Pioneer6000SetVideo(theObject, FeatureOn);
  495.   Pioneer6000Still(theObject);
  496.   for (i = 0; i < 30; i++)
  497.     Pioneer6000SendCode(theObject, "F8", 0);
  498.   return (Pioneer6000Play(theObject));
  499. }                                    /* end function Pioneer6000Reverse */
  500.  
  501.  
  502. int
  503.   Pioneer6000PlayAtSpeedDir(VideoObject*    theObject,
  504.                 int            framesPerSecond,
  505.                 enum Direction    direction)
  506. {
  507.   int        timesSpeed;
  508.   int        denom;
  509.   char        command[10];
  510.   char        speed[7];
  511.   static int    lastSpeed = 0;
  512.   
  513.   if (framesPerSecond == lastSpeed)                    /* Was a new speed requested? */
  514.     return(PlayerOk);                            /* No, don't bother sending a new command to the player */
  515.   
  516.   lastSpeed = framesPerSecond;                        /* Update last speed requested */
  517.   if (framesPerSecond == 0)
  518.     return(Pioneer6000Still(theObject));
  519.   if (MyAbs(framesPerSecond) < FrameRate)                /* Set speeds */
  520.   {
  521.     denom = MyRound(FrameRate, framesPerSecond);
  522.     IntToCode(denom, speed);
  523.     sprintf(command, "%sED", speed);
  524.   }
  525.   else
  526.   {
  527.     timesSpeed = MyRound(framesPerSecond, FrameRate);
  528.     if (timesSpeed > 3)
  529.       timesSpeed = 3;
  530.     IntToCode(timesSpeed, speed);
  531.     sprintf(command, "%sEC", speed);
  532.   }
  533.   Pioneer6000SetVideo(theObject, FeatureOn);
  534.   Pioneer6000SendCode(theObject, command, 0);                /* Send command to set speed */
  535.   if (direction == Forward)        
  536.     if (sliderControl)
  537.       return(Pioneer6000SendCode(theObject, "F2", 0));            /* Fast forward if slider control */
  538.     else
  539.     {
  540.       sliderControl = 1;
  541.       return(Pioneer6000SendCode(theObject, "CF", 0));            /* Run program otherwise */
  542.     }
  543.   else                                    /* Rewind */
  544.     return(Pioneer6000SendCode(theObject, "FA", 0));
  545. }                                    /* end function Pioneer6000PlayAtSpeedDir */
  546.  
  547.  
  548.  
  549. /* Returns number of frames per second.
  550.  */
  551. int
  552.   Pioneer6000CalcSpeed(VideoObject*    theObject,
  553.                int        sliderValue,
  554.                int        playMode)            /* unused */
  555. {
  556.   int    denom;
  557.   int    deviceSpeed;                            /* in frames per second */
  558.   
  559.   if (sliderValue == 0)
  560.     return(0);
  561.   if (MyAbs(sliderValue) < FrameRate)
  562.   {
  563.     denom = MyRound(FrameRate, sliderValue);                /* Bring to the nearest rounded denom */
  564.     deviceSpeed = (FrameRate / denom);
  565.   }
  566.   else
  567.   {
  568.     deviceSpeed = MyRound(sliderValue, FrameRate) * FrameRate;        /* Bring to nearest whole number */
  569.     if (deviceSpeed > (3 * FrameRate))
  570.       deviceSpeed = FrameRate;
  571.   }
  572.   sprintf(diagMsg, "%s :\tDevice speed : %d.\n",
  573.       theObject->DevConfig->serialPort,
  574.       deviceSpeed);
  575.   PrintDiagnostics(diagMsg);
  576.   return(deviceSpeed);
  577. }                                    /* end function Pioneer6000CalcSpeed */
  578.  
  579.  
  580.  
  581. int
  582.   Pioneer6000Search(VideoObject*    theObject,
  583.             int            to)
  584. {
  585.   char command[13];
  586.   char address[11];
  587.   
  588.   IntToCode(to, address);
  589.   sprintf(command, "%sF7", address);
  590.   Pioneer6000SetVideo(theObject, FeatureOn);
  591.   return(Pioneer6000SendCode(theObject, command, 0));
  592. }                                    /* end function Pioneer6000Search */
  593.  
  594.  
  595.  
  596. int
  597.   Pioneer6000SetAddressDisplay(VideoObject*    theObject,
  598.                    int        on,
  599.                    int        mode)            /* unused */
  600. {
  601.   if (on == FeatureOn) 
  602.   {
  603.     Pioneer6000SendCode(theObject, "E0", 0);                /* Set character generator on */
  604.     return(Pioneer6000SendCode(theObject, "0FF1", 0));
  605.   }
  606.   else 
  607.     return(Pioneer6000SendCode(theObject, "3FF1", 0));
  608. }                                    /* end function Pioneer6000SetAddressDisplay */
  609.  
  610.  
  611.  
  612. int
  613.   Pioneer6000SetAudio(VideoObject*    theObject,
  614.               int        ac)
  615. {
  616.   switch (ac)
  617.   {
  618.    case PlayerAudioMute:
  619.     return(Pioneer6000SendCode(theObject, "A0", 0));
  620.    case PlayerAudioLeft:
  621.     return(Pioneer6000SendCode(theObject, "A1", 0));
  622.    case PlayerAudioRight:
  623.     return(Pioneer6000SendCode(theObject, "A2", 0));
  624.    case PlayerAudioStereo:
  625.     return(Pioneer6000SendCode(theObject, "A3", 0));
  626.   }
  627. }                                    /* end function Pioneer6000SetAudio */
  628.  
  629.  
  630. int
  631.   Pioneer6000SetVideo(VideoObject*    theObject,
  632.               int        vc)
  633. {
  634.   if (vc==FeatureOn)
  635.     return(Pioneer6000SendCode(theObject, "1B", 0));
  636.   else
  637.     return(Pioneer6000SendCode(theObject, "1C", 0));
  638. }                                    /* end function Pioneer6000SetVideo */
  639.  
  640.  
  641.  
  642. int
  643.   Pioneer6000QueryFrame(VideoObject* theObject)
  644. {  
  645.   return(Pioneer6000SendCode(theObject, "D3", 1));
  646. }                                    /* end function Pioneer6000QueryFrame */
  647.  
  648.  
  649. int
  650.   Pioneer6000QueryStatus(VideoObject* theObject)
  651. {  
  652.   return(Pioneer6000SendCode(theObject, "D4", 1));
  653. }                                    /* end function Pioneer6000QueryStatus */
  654.  
  655.  
  656.  
  657. int 
  658.   Pioneer6000Ping(VideoObject* theObject)
  659. {  
  660.   int    nr;
  661.   char    response[3];
  662.   
  663.   write(theObject->DevConfig->fd, "D5", 2);                /* Transmit extended status command */
  664.   sprintf(diagMsg, "%s :\tSent ping.\n",
  665.       theObject->DevConfig->serialPort);
  666.   PrintDiagnostics(diagMsg);
  667.   nr = read(theObject->DevConfig->fd, response, 3);
  668.   if (nr)
  669.   {
  670.     sprintf(diagMsg, "%s :\tSuccessful ping.\n",
  671.         theObject->DevConfig->serialPort);
  672.     PrintDiagnostics(diagMsg);
  673.   }
  674.   
  675.   else
  676.   {
  677.     sprintf(diagMsg, "%s :\tPing unsuccessful.\n",
  678.         theObject->DevConfig->serialPort);
  679.     PrintDiagnostics(diagMsg);
  680.   }
  681.   
  682.   return nr;
  683. }                                    /* end function Pioneer6000Ping */
  684.